package com.zxct.wyserver;

import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;

import com.socks.library.KLog;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zxct.wyserver.crash.CrashHandler;
import com.zxct.wyserver.http.NetworkInterceptor;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;

/**
 * Created by lanyu on 2018/1/29.
 */

public class MyApp extends Application {

    private static Context context;

    @Override
    public void onCreate() {
        super.onCreate();
        context = this;

        MultiDex.install(context);//解决65533方法书问题
        KLog.init(BuildConfig.DEBUG, "lanyu");
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .addInterceptor(new NetworkInterceptor())
                .connectTimeout(60000L, TimeUnit.MILLISECONDS)
                .readTimeout(60000L, TimeUnit.MILLISECONDS)
                //其他配置
                .build();                       //okhttp初始化

        OkHttpUtils.initClient(okHttpClient);

//        CrashHandler crashHandler = CrashHandler.getInstance();
//        crashHandler.init(getApplicationContext());    //全局捕获异常工具初始化
    }

    /**
     * 获取Application类型的上下文
     */
    public static Context getContext() {
        return context;
    }
}
